import grayFilter from './grayscale.js'

// 木雕效果
const woodCarving = function(imageData) {
    var data = imageData.data;
    //阀值越小则线越多
    var value = 10;
    //需调用灰度化方法
    grayFilter(imageData);

    for (var i = 0; i < data.length; i++) {
        if ((i + 1) % 4 !== 0) {
            //点灰度与临近点灰度变化值
            var c = Math.abs(data[i] - data[i + 4]);

            if (c > value)
            data[i] = 255;
            else
            data[i] = 0;
        }
    }

    return imageData;
}

export default woodCarving;